<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/pop-ups.css"><!--弹出层-->
    <link rel="stylesheet" href="../../css/icon-font.css"/><!--图标-->
    <link rel="stylesheet" href="../../plugin/mescroll/css/mescroll.min.css">
    <title>系列专题更多</title>
    <style>
        body {
            background-color: white;
        }

        .placeholder-top {
            z-index: 100001;
        }

        .special-video-list-wrap {
            background-color: white;
            position: relative;
            /*top: -0.8rem;*/
            z-index: 10;
            border-radius: 0.16rem 0.16rem 0 0;
        }

        .special-video-item {
            padding: 0.36rem 0;
            border-bottom: 0.02rem solid #F2F2F2;
        }

        .special-video-item-left {
            width: 2.8rem;
            height: 1.6rem;
            position: relative;
        }

        .special-video-item-left-img {
            width: 2.8rem;
            height: 1.6rem;
        }

        .special-video-item-left-img img {
            width: 100%;
            height: 100%;
            border-radius: 0.04rem;
        }

        .special-video-item-time {
            position: absolute;
            top: 1.2rem;
            right: 0.1rem;
        }

        .special-video-item-time div {
            background-color: rgba(0, 0, 0, 0.25);
            color: rgba(255, 255, 255, 0.8);
            padding: 0.02rem 0.08rem;
        }

        .special-video-item-title {
            color: #222222;
        }

        .special-video-item-bottom {
            color: rgba(34, 34, 34, 0.45);
        }


        .special-video-head {
            height: 3.92rem;
            width: 7.5rem;
        }

        .special-video-img {
            min-height: 4.36rem;
        }

        .special-video-img img {
            width: 100%;
            height: 4.36rem;
        }

        .special-video-bg {
            top: 0;
            left: 0;
            width: 100%;
            height: 4.36rem;
            background-color: rgba(0, 0, 0, 0.5);
        }

        .special-video-info {
            width: 100%;
            top: 1.74rem;
            left: 0;
            padding: 0 .32rem;
        }

        .special-video-title {
            line-height: .56rem;
            height: .56rem;
            color: rgba(255, 255, 255, 1);
        }

        .special-video-count {
            line-height: .34rem;
            height: .58rem;
            width: 100%;
            padding: 0.08rem 0 0.16rem 0;
            border-bottom: 0.02rem solid rgba(255, 255, 255, 0.29);
            color: rgba(255, 255, 255, 0.6);
        }

        .special-video-count span {
            color: white;
        }

        .special-video-desc {
            margin-top: 0.16rem;
            color: #FFFFFF;
            max-width: 5.6rem;
        }

        .special-video-btn {
            margin-top: 0.16rem;
            color: #FF9523;
        }


    </style>
</head>
<body>

<div class="flex-column ff400 h-100-p fs14">
    <div class="placeholder-top pos-f">
        <!--状态栏-->
        <div class="status-bar pos-f"></div>
        <!--标题栏-->
        <div class="nav-bar pos-f flex-row justify-content-between c-white align-items-center">
            <div class="left-bar" onclick="goBack()" style="color: #FFFFFF;">
                <span class="iconfont iconfanhui1 fs16"></span>
            </div>
            <div class="center-bar fs16 ff500 line1"></div>
            <div class="right-bar">
            </div>
        </div>
    </div>
    <div class="mescroll" id="mescroll">
        <div class="special-video-head pos-r">
            <div class="special-video-img"><img src=""></div>
            <div class="special-video-bg pos-a"></div>
            <div class="flex-column special-video-info pos-a">
                <div class="special-video-title fs20 ff600 line1"></div>
                <div class="special-video-count fs12"></div>
                <div class="flex-row fs12">
                    <div class="special-video-desc line1"></div>
                    <div class="special-video-btn"></div>
                </div>
            </div>
        </div>

        <div class="special-video-list-wrap flex-column pt5 pb20">
            <div class="flex-column" style="padding: 0 0.32rem;">
                <!--系列专题视频列表-->
                <div class="special-video-list">

                </div>
            </div>
        </div>
    </div>
</div>


</body>
<!--这四个文件的引入必须按照顺序-->
<script src="../../js/dict.js"></script>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/checkJsBridge.js"></script>
<script src="../../js/utils.js"></script>
<script src="../../js/api.js"></script>
<!--这四个文件的引入必须按照顺序-->
<script src="../../js/date.js"></script>
<script src="../../js/icon-font.js"></script><!--用于彩色字体图标-->
<script src="../../js/template.js"></script>

<script src="../../plugin/mescroll/js/mescroll.min.js"></script>

<script>
  let pm = {
    isScroll: false,
    pageNum: 1,
    pageSize: 10,
    funcCode: '',
    readCnt: 0,
    title: ''
  }

  function initPage(params) {
    //状态栏自适应
    Utils.sbhAdaptive()
    pm.funcCode = params.funcCode

    pageScroll()

    //下拉刷新、滚动加载
    meScroll = Template.createMeScroll({
      id: 'mescroll', //区域ID
      pageNum: pm.pageNum,
      downCallback: reLoadPage, //下拉刷新入口
      upCallback: getTrainListByFuncCode //滚动加载入口
    })
  }

  function reLoadPage() {
    pm.isScroll = false//初始化滚动状态
    pm.pageNum = 1
    pm.lastDttm = DateUtils.getNowInt()
    pm.title = ''

    selectFuncInfoByFuncCode()//系列专题详情
    getTrainListByFuncCode()//查询系列专题列表
  }

  //查询系列专题详情
  function selectFuncInfoByFuncCode() {
    Server.specialVideo.selectFuncInfoByFuncCode({
      funcCode: pm.funcCode
    }).then(function (data) {
      $('.special-video-img img').attr('src', data.body.coverImgUrl)
      $('.special-video-title').html(data.body.funcName)
      pm.title = data.body.funcName
      pm.readCnt = data.body.readCnt
      $('.special-video-count').html('共<span>' + data.body.articleCnt + '</span>个视频')

      if (data.body.introduction) {
        $('.special-video-desc').html(data.body.introduction)
        if (data.body.introduction.length > 22) {
          $('.special-video-btn').html('查看更多')
        }
      }
      $('.special-video-btn').click(function () {
        Template.bottomPop(data.body.funcName, data.body.introduction)
      })

    })
  }

  //查询系列专题列表
  function getTrainListByFuncCode() {
    Server.specialVideo.getTrainListByFuncCode({
      funcCode: pm.funcCode,
      pageNum: pm.pageNum,
      pageSize: pm.pageSize
    }).then(function (data) {
      let htmlStr = ''
      let len = 0
      if (data.trainList !== null) {
        len = data.trainList.length
        data.trainList.forEach(function (item) {
          let jsonStr = JSON.stringify({
            infoId: item.trainingId,
            infoType: '2',
            resourceType: '2'
          })
          htmlStr += '<div class=\'special-video-item flex-row\' onclick=\'goDetail(' + jsonStr + ')\'>'
          htmlStr += '<div class=\'flex-row mr15 special-video-item-left\'>'
          htmlStr += '<div class=\'special-video-item-left-img\'>'
          htmlStr += '<img src=' + item.coverImgUrl + ' />'
          htmlStr += '</div>'
          htmlStr += '<div class=\'special-video-item-time flex-row\'>'
          htmlStr += '<div class=\'fs12\'>' + DateUtils.s2Str(item.videoDuration) + '</div>'
          htmlStr += '</div>'
          htmlStr += '</div>'
          htmlStr += '<div class=\'special-video-item-content flex-column justify-content-between flex-1\'>'
          htmlStr += '<div class=\'special-video-item-title fs15 ff600 line2\'>' + item.mainTitle + '</div>'
          htmlStr += '<div class=\'special-video-item-bottom flex-row justify-content-between align-items-center\'>'
          htmlStr += '<div class=\'fs13\'>' + item.lecturer + '</div>'
          htmlStr += '<div class=\'flex-row align-items-center\'>'
          htmlStr += '<span class=\'iconfont iconbofangliang-01 mr5\'></span>'
          htmlStr += '<span class="readCnt_' + item.trainingId + '">' + item.readCnt + '</span>'
          htmlStr += '</div>'
          htmlStr += '</div>'
          htmlStr += '</div>'
          htmlStr += '</div>'
        })

        if (pm.pageNum === 1) {
          $('.special-video-list').html(htmlStr)
        } else {
          $('.special-video-list').append(htmlStr)
        }
      }

      pm.pageNum ++
      meScroll.endSuccess(len, len === pm.pageSize)
    }).catch((error) => {
      meScroll.endErr()
    })
  }


  /**
   * @param callback 翻页回调函数
   */
  function pageScroll(callback) {
    //需要特殊处理的滚动区域，需要放在scroller元素区域内
    $('.mescroll').scroll(function () {
      let scrollTop = $(this).scrollTop()

      dealHead(scrollTop)

    })
  }

  //处理状态栏滚动效果
  function dealHead(scrollTop) {
    let currStop
    if (scrollTop < 64) {
      currStop = scrollTop
      $('.center-bar').html('')
      $('.left-bar').css({
        'color': 'rgb(255,255,255)'
      })
    } else {
      currStop = 64
      $('.center-bar').html(pm.title)
      $('.left-bar').css({
        'color': 'rgba(34, 34, 34, ' + currStop / 64 + ')'
      })
    }
    $('.placeholder-top').css({
      'background': 'rgba(255, 255, 255, ' + currStop / 64 + ')'
    })
  }

  function goBack() {
    jsBridge.goBack({
      readCnt: pm.readCnt
    })
  }

</script>
</html>
